import * as actionTypes from "./constants";

import { getArtistList } from "@/services/artist";

const changeArtistListAction = (artistList) => ({
  type: actionTypes.CHANGE_ARTIST_LIST,
  artistList
});

export const changeCurrentAreaAction = (area) => ({
  type: actionTypes.CHANGE_CURRENT_AREA,
  area
});

export const changeCurrentTypeAction = (currentType) => ({
  type: actionTypes.CHANGE_CURRENT_TYPE,
  currentType
});

export function getArtistListAction(area, type, initial) {
  return dispatch => {
    getArtistList(area, type, initial).then(res => {
      dispatch(changeArtistListAction(res.artists));
    })
  }
};
